﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06_获取属性或方法的强类型委托
{
    class Program
    {
        static void Main(string[] args)
        {
            var tArgs = new Type[] { typeof(int), typeof(int) };
            var maxMethod = typeof(Math).GetMethod("Max", tArgs);
            var strongTypeDelegate = (Func<int, int, int>)Delegate.CreateDelegate(typeof(Func<int, int, int>), null, maxMethod);
            Console.WriteLine("3 和 5 之间最大的是：{0}", strongTypeDelegate(3, 5)); // 输出：5
            Console.ReadKey();
        }
    }
}
